package com.wish;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;


public class SlcApplication {

    public static ConfigurableApplicationContext run(Class clazz){
        System.out.println("SlcApplication on start.");
        AnnotationConfigWebApplicationContext webApplicationContext = new AnnotationConfigWebApplicationContext();
        webApplicationContext.register(clazz);
        webApplicationContext.refresh();
        runWebServer(webApplicationContext);
        return null;
    }
    private static void runWebServer(WebApplicationContext webApplicationContext) {
        WebServer webServer = webApplicationContext.getBean(WebServer.class);
        webServer.onStart(webApplicationContext);
    }
}
